﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    
    <Style TargetType="{x:Type DataGrid}" x:Key="DataGridStyle">
        
        <Setter Property="AutoGenerateColumns" Value="False"/>
        <Setter Property="Background" Value="#E5F1E4"/>
        <Setter Property="IsReadOnly" Value="True"/>
        <Setter Property="HeadersVisibility" Value="Column"/>
        <!--<Setter Property="AlternationCount" Value="2"/>-->
        <!--<Setter Property="GridLinesVisibility" Value="Vertical"/>-->
        <Setter Property="SelectionMode" Value="Extended"/>
        <Setter Property="ClipboardCopyMode" Value="IncludeHeader"/>
        <!--<Setter Property="VerticalGridLinesBrush" Value="#C6D7C5"/>-->
        <Setter Property="SelectionUnit" Value="FullRow"/>
    </Style>

    <Style x:Key="DataGridColumnHeaderStyle1" TargetType="{x:Type DataGridColumnHeader}">
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Height" Value="35" />
        <Setter Property="SeparatorBrush" Value="DarkRed" />
        <Setter Property="FontWeight" Value="Black" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
                    <Grid>
                        <Border x:Name="columnHeaderBorder"
		BorderThickness="1"
		Padding="3,0,3,0">
                            <Border.BorderBrush>
                                <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                                    <GradientStop Offset="0" Color="#A5A5A5" />
                                    <GradientStop Offset="1" Color="#4B4B4B" />
                                </LinearGradientBrush>
                            </Border.BorderBrush>
                            <Border.Background>
                                <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                                    <GradientStop Offset="0" Color="#DEB40A" />
                                    <GradientStop Offset="1" Color="#FF7F00" />
                                </LinearGradientBrush>
                            </Border.Background>
                            <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
			     VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
				SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type DataGridCell}" x:Key="DataGridCellStyle">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="DataGridCell">
                    <Border BorderThickness="{TemplateBinding Border.BorderThickness}" 
                    BorderBrush="{TemplateBinding Border.BorderBrush}" 
                    Background="{TemplateBinding Panel.Background}" SnapsToDevicePixels="True">
                        <ContentPresenter VerticalAlignment="Center"
                                  Content="{TemplateBinding ContentControl.Content}" 
                                  Margin="1,0,0,0"
                                  ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" 
                                  ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}" 
                                  SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>

        <Style.Triggers>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="Background" Value="{StaticResource SelectedItemListBrush}" />
                <Setter Property="Foreground" Value="Black"/>
                <Setter Property="BorderBrush" Value="Transparent" />
            </Trigger>
            <Trigger Property="DataGridRow.IsFocused" Value="True">
                <Setter Property="BorderBrush" Value="Transparent" />
            </Trigger>
        </Style.Triggers>
    </Style>
    
    <Style TargetType="DataGridColumnHeader" x:Key="DataGridColumnHeaderStyle">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
                    <ControlTemplate.Resources>
                        <Style TargetType="{x:Type Thumb}">
                            <Setter Property="FrameworkElement.Width" Value="1"/>
                            <Setter Property="FrameworkElement.Cursor" Value="SizeWE"/>
                            <Setter Property="Control.Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="Thumb">
                                        <Border Background="{TemplateBinding Background}" />
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                        <Style x:Key="SortPathStyle" TargetType="{x:Type Path}">
                            <Setter Property="Fill" Value="Green"/>
                            <Setter Property="HorizontalAlignment" Value="Right"/>
                            <Setter Property="VerticalAlignment" Value="Center"/>
                            <Setter Property="Margin" Value="0,2,7,0"/>
                            <Setter Property="Visibility" Value="Hidden"/>
                        </Style>
                    </ControlTemplate.Resources>
                    <Grid>
                        <Border Name="MainBorder" >
                            <!--<Border.Background>
                    <ImageBrush ImageSource="modules_view_grid_header_background.png"/>
                </Border.Background>-->
                            <Grid>
                                <ContentPresenter Margin="3" 
                                  HorizontalAlignment="Center" 
                                  VerticalAlignment="Center" 
                                  Content="{TemplateBinding Content}"
                                  ContentStringFormat="{TemplateBinding ContentStringFormat}" 
                                  ContentTemplate="{TemplateBinding ContentTemplate}"/>
                            </Grid>
                        </Border>
                        <Path Name="UpArrow" Style="{StaticResource SortPathStyle}">
                            <Path.Data>
                                <PathGeometry>
                                    <PathFigure StartPoint="0,0">
                                        <LineSegment Point="7,0"/>
                                        <LineSegment Point="3.5,6"/>
                                        <LineSegment Point="0,0"/>
                                    </PathFigure>
                                </PathGeometry>
                            </Path.Data>
                        </Path>
                        <Path Name="DownArrow" Style="{StaticResource SortPathStyle}">
                            <Path.Data>
                                <PathGeometry>
                                    <PathFigure StartPoint="0,6">
                                        <LineSegment Point="7,6"/>
                                        <LineSegment Point="3.5,0"/>
                                        <LineSegment Point="0,6"/>
                                    </PathFigure>
                                </PathGeometry>
                            </Path.Data>
                        </Path>
                        <Thumb Name="PART_LeftHeaderGripper" HorizontalAlignment="Left"
               Background="#F7FEF7"/>
                        <Thumb Name="PART_RightHeaderGripper" HorizontalAlignment="Right"
               Background="#C6D7C5"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="SortDirection" Value="Descending">
                            <Setter TargetName="UpArrow" Property="Visibility" Value="Hidden"/>
                            <Setter TargetName="DownArrow" Property="Visibility" Value="Visible"/>
                        </Trigger>
                        <Trigger Property="SortDirection" Value="Ascending">
                            <Setter TargetName="DownArrow" Property="Visibility" Value="Hidden"/>
                            <Setter TargetName="UpArrow" Property="Visibility" Value="Visible"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <SolidColorBrush x:Key="DataGridHeaderSortedBackgroundBrush" Color="YellowGreen"/>
    <SolidColorBrush x:Key="DataGridHeaderSortedBorderBrush" Color="Gray"/>
    
    <Style x:Key="DatagridColumnHeaderCustomTemplateStyle" 
         TargetType="{x:Type DataGridColumnHeader}">
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="MinWidth" Value="0" />
        <Setter Property="MinHeight" Value="28" />
        <Setter Property="Foreground" Value="White" />
        <Setter Property="Cursor" Value="Hand" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Border x:Name="BackgroundBorder" BorderThickness="0,1,0,1" 
                              Background="{StaticResource DataGridHeaderSortedBackgroundBrush}" 
                              BorderBrush="{StaticResource DataGridHeaderSortedBorderBrush}" 
                              Grid.ColumnSpan="2" />
                        <ContentPresenter Margin="6,3,6,3" VerticalAlignment="Center" />
                        <Path x:Name="SortArrow" Visibility="Collapsed" Data="M0,0 L1,0 0.5,1 z" Stretch="Fill" 
                            Grid.Column="1" Width="8" Height="6" Fill="White" Margin="0,0,8,0" 
                            VerticalAlignment="Center" RenderTransformOrigin="0.5,0.4" />
                        <Rectangle Width="1" Fill="#AAC377" HorizontalAlignment="Right" Grid.ColumnSpan="2" />

                        <Rectangle Width="1" Margin="0,0,1,0" Fill="#425B10" 
                                 HorizontalAlignment="Right" Grid.ColumnSpan="2" />
                        <Thumb x:Name="PART_LeftHeaderGripper" HorizontalAlignment="Left" 
                             Style="{StaticResource ColumnHeaderGripperStyle}"/>
                        <Thumb x:Name="PART_RightHeaderGripper" HorizontalAlignment="Right" 
                             Style="{StaticResource ColumnHeaderGripperStyle}"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="SortDirection" Value="{x:Null}">
                            <Setter TargetName="BackgroundBorder" Property="Background" 
                                  Value="{DynamicResource DataGridHeaderBackgroundBrush}" />
                            <Setter TargetName="BackgroundBorder" Property="BorderBrush"  
                                  Value="Transparent" />
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="True" />
                                <Condition Property="SortDirection" Value="{x:Null}" />
                            </MultiTrigger.Conditions>
                            <Setter Property="Background" TargetName="BackgroundBorder" 
                                  Value="{StaticResource DataGridHeaderMouseOverBackgroundBrush}" />
                            <Setter Property="BorderBrush" TargetName="BackgroundBorder" 
                                  Value="{StaticResource DataGridHeaderBorderBrush}" />
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="true" />
                                <Condition Property="SortDirection" Value="{x:Null}" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="BackgroundBorder" Property="Background" 
                                  Value="{StaticResource DataGridHeaderMouseOverBackgroundBrush}" />
                            <Setter TargetName="BackgroundBorder" Property="BorderBrush" 
                                  Value="{StaticResource DataGridHeaderBorderBrush}" />
                        </MultiTrigger>

                        <Trigger Property="SortDirection" Value="Ascending">
                            <Setter TargetName="SortArrow" Property="Visibility" Value="Visible" />
                            <Setter TargetName="SortArrow" Property="RenderTransform">
                                <Setter.Value>
                                    <RotateTransform Angle="180" />
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <Trigger Property="SortDirection" Value="Descending">
                            <Setter TargetName="SortArrow" Property="Visibility" Value="Visible" />
                        </Trigger>
                        <Trigger Property="DisplayIndex" Value="0">
                            <Setter Property="Visibility" Value="Collapsed" 
                                  TargetName="PART_LeftHeaderGripper"></Setter>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>